#!/bin/bash
if [ "$#" -lt 3 ]; then
	echo "Incorrect args. invoke gluster-swift-add-user $S3_USER $S3_PASSWORD $S3_ACCOUNT"
	exit 1
else
	S3_USER=$1
	S3_PASSWORD=$2
	S3_ACCOUNT=$(echo $3 | cut -d" " -f1)
	sleep 5
	gswauth-prep -A http://0.0.0.0:8080/auth -K gswauthkey
        gswauth-add-account -K gswauthkey $S3_ACCOUNT
	gswauth-add-user -K gswauthkey -a $S3_ACCOUNT $S3_USER $S3_PASSWORD
	systemctl restart swift-proxy.service
	systemctl restart swift-account.service
fi
